import { createRouter, createWebHashHistory } from "vue-router";

import Layout from "../components/Layout.vue"

const routes = [{
            path: "/login",
            component: () =>
                import ("../views/Login.vue"),
            meta: { title: "登录" }
        },
        {
            path: "/",
            component: Layout,
            meta: { title: "首页" },
            redirect: "/home",
            children: [{
                path: "home",
                meta: { title: "首页" },
                component: () =>
                    import ("../views/Home.vue")
            }]
        },
        {
            path: "/teacher",
            component: Layout,
            meta: { title: "讲师管理" },
            children: [{
                    path: "list",
                    meta: { title: "讲师列表" },
                    component: () =>
                        import ("../views/teacher/list.vue")
                },
                {
                    path: "create",
                    meta: { title: "添加讲师" },
                    component: () =>
                        import ("../views/teacher/form.vue")
                }
            ]
        },
        {
            path: "/course",
            component: Layout,
            meta: { title: "课程管理" },
            children: [{
                    path: "list",
                    meta: { title: "课程列表" },
                    component: () =>
                        import ("../views/course/list.vue")
                },
                {
                    path: "create",
                    meta: { title: "添加课程" },
                    component: () =>
                        import ("../views/course/form.vue")
                }
            ]
        }
    ]
    // 通过createRouter方法创建路由
const router = createRouter({
    history: createWebHashHistory(), //has模式
    routes
})

export default router